/** \file lp_app.h
 * \brief Header file for the gladefile loader.
 * \author Marcelo Lira dos Santos
 * \date 2006-2007
 *
 * This is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License, see the file LICENSE.
 */
#ifndef __LP_APP_H
#define __LP_APP_H
#include <gtk/gtk.h>
#include <glade/glade.h>
#include "logicparser.h"
#include "lp_graph.h"

// Constants
// For testing propose use the local (not installed) glade file
//#define GLADE_FILE PACKAGE_GLADE_DIR"/lp_gui.glade"
#define GLADE_FILE	"lp_gui.glade"

// Data Types
typedef struct _LpApp
{
	GladeXML *widgetTree;
	GtkWidget *lpWindow;
	GtkWidget *exprEntry;
	GtkWidget *parsedTree;
	GtkWidget *graphText;
	GtkWidget *graphImage;
	GtkTreeStore *parsedTreeModel;
	GtkTextBuffer *graphTextBuffer;
	GtkWidget *imageToolbar;
	GtkWidget *dotToolbar;
} LpApp;

// Macros
#define LPAPP_TO_GPOINTER(a)	((gpointer)	(a))
#define GPOINTER_TO_LPAPP(p)	((LpApp *)	(p))

// Functions
LpApp *lp_app_init (gchar *gladefile);
void lp_app_init_tree (LpApp *lpApp);
void lp_app_init_text (LpApp *lpApp);
void lp_app_run (LpApp *lpApp);
void lp_app_update_tree (LpApp *lpApp, LpNode *root);
void lp_app_update_graph (LpApp *lpApp, LpNode *root);
void lp_app_add_node (GtkTreeStore *parsedTreeModel,
							GtkTreeIter *parent,
							LpNode *node);
gchar *save_file ();

// Callbacks
void quit_cb (GtkWidget *widget, GdkEventKey *e);
void parse_cb (GtkWidget *widget, gpointer data);
void save_image_cb (GtkWidget *widget, gpointer data);
void save_dot_cb (GtkWidget *widget, gpointer data);
void zoom_in_cb (GtkWidget *widget, gpointer data);
void zoom_out_cb (GtkWidget *widget, gpointer data);
void normal_view_cb (GtkWidget *widget, gpointer data);


#endif // LP_APP
